#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<algorithm>
using namespace std;
int sum;
double t,ans;
int main()
{
	int n, m;
	cin >> n >> m;
	int maxx = 0;
	int minx = 10;
	for (int i = 1; i <= n; i++)
	{
		sum = 0;
		maxx = 0;
		minx = 10;
		for (int j = 1; j <= m; j++)
		{
			int x;
			cin >> x;
			sum += x;
			maxx = max(maxx, x);
			minx = min(minx, x);
		}
		t = 1.0 * (sum - maxx - minx) / (m - 2);
		ans = max(ans, t);
	}
	printf("%.2f\n", ans);
	return 0;
}